<?php
namespace Tbf\Bundle\ImageBundle\Tests;
use Symfony\Component\Yaml\Yaml;
use Tbf\Bundle\ImageBundle\ImageUtil;
use Tbf\Bundle\TestBundle\TestSuite\TbfTestCase;

class ImageUtilTest extends TbfTestCase{
    function testRotationPoint(){
$test_case = Yaml::parse(<<<YML
- input: {base_x:13,base_y:32,rel_x:0,rel_y:-13,hex:90}
  output: {x:0,y:32}
- input: {base_x:13,base_y:32,rel_x:13,rel_y:-13,hex:90}
  output: {x:0,y:19}
- input: {base_x:13,base_y:32,rel_x:1,rel_y:1,hex:0}
  output: {x:14,y:33}
YML
);
        foreach($test_case as $case){
            $this->assertEquals($case['output'],ImageUtil::rotationPoint($case['input']));
        }
    }
    function testCheckPointInsideRectangle(){
        $test_case = Yaml::parse(<<<YML
- input: {x_min:0,x_max:100,y_min:0,y_max:100,x:90,y:105}
  output: false
- input: {x_min:0,x_max:100,y_min:0,y_max:100,x:90,y:99}
  output: true
- input: {x_min:0,x_max:100,y_min:0,y_max:100,x:0,y:100}
  output: true
YML
        );
        foreach($test_case as $case){
            $this->assertEquals($case['output'],ImageUtil::checkPointInsideRectangle($case['input']));
        }
    }
    function testCheckFontRotateIsOut(){
        $test_case = Yaml::parse(<<<YML
- input: {pos_x:13,pos_y:32,height:18,width:13,rel_x:0,rel_y:13,max_x:75,max_y:32,hex:90}
  output: true
- input: {pos_x:13,pos_y:32,height:18,width:13,rel_x:0,rel_y:13,max_x:75,max_y:32,hex:91}
  output: false
- input: {pos_x:13,pos_y:32,height:18,width:13,rel_x:0,rel_y:13,max_x:75,max_y:32,hex:89}
  output: true
YML
        );
        foreach($test_case as $case){
            $this->assertEquals($case['output'],ImageUtil::checkFontRotateIsOut($case['input']));
        }
    }
}